<!-- 各类状态弹窗组件 -->
<template>
  <u-popup
    :show="pShow"
    :round="10"
    closeOnClickOverlay
    @close="pShow = false"
    mode="center"
    :safeAreaInsetBottom="false"
  >
    <view class="statusPopup py-20">
      <template v-if="showOfficial">
        <view class="tc fz-16 fw-6">关注公众号</view>
        <view class="tc fz-12 color9 pt-8">关注公众号 快速接收消息/通知</view>
        <image
          class="my-20"
          src="https://onelive.obs.cn-south-1.myhuaweicloud.com/uniapp/static/padLogo.png"
          style="width: 200rpx; height: 200rpx"
        />
        <view class="accountBox1">
          <view class="accountBox2">
            <official-account @binderror="officialErr"></official-account>
          </view>
        </view>
      </template>
      <template v-if="!showOfficial"> 
        <view class="tc fz-16 fw-6">扫码关注</view>
        <view class="tc fz-12 color9 pt-8">关注公众号 快速接收消息/通知</view>
        <image
          class="my-20"
          src="https://onelive.obs.cn-south-1.myhuaweicloud.com/uniapp/static/accountQrcode.png"
          style="width: 264rpx; height: 264rpx"
          show-menu-by-longpress
        />
        <view class="tc" style="color:#F56c6c;"
          >长按二维码识别，或截图保存</view
        >
      </template>
    </view>
  </u-popup>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    // 按钮文字
    btnText: {
      type: String,
      default: "已关注",
    },
  },
  watch: {
    show(nval) {
      this.pShow = nval;
    },
    pShow(nval) {
      if (!nval) {
        this.$emit("close");
      }
    },
    mpOpenid(nval,oval){
      if(!oval && nval){
        console.log("操作关注公众号,执行关闭弹窗");
        this.$emit("close");
      }
    }
  },
  computed: {
    // 是否为扫码进入
    showOfficial() {
      let sceneList = [1011, 1025, 1047, 1124];
      let scene = uni.getLaunchOptionsSync().scene; // 当前场景值
      console.log(scene, sceneList.includes(scene));
      return sceneList.includes(scene);
    },
    // 是否关注公众号
    mpOpenid() {
      return this.$store.state.userInfo.mpOpenid
    }
  },
  data() {
    return {
      pShow: false,

    };
  },
  methods: {
    confirmFn() {
      this.$emit("confirm");
    },
    officialErr(detail){
      console.log(detail,'关注公众号加载失败');
    }
  },
};
</script>

<style lang="scss" scoped>
.statusPopup {
  width: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .accountBox1 {
    position: relative;
    width: 240px;
    height: 63px;
    overflow: hidden;
    .accountBox2 {
      position: absolute;
      top: -20px;
      left: -49px;
      width: 300px;
      height: 84px;
    }
  }
}
</style>